// 多数元素

// hash映射
class Solution {
public:
    int majorityElement(vector<int>& nums) {
        int size = nums.size();
        int count = size / 2;
        unordered_map<int, int> counts;
        for(auto& x : nums)
        {
            counts[x]++;
        }
        int answer = -1;
        for(auto it = counts.begin(); it != counts.end(); ++it)
        {
            if(it->second > count)
            {
                answer = it->first;
            }
        }
        return answer;
    }
};
